package vn.net.click.dao;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

import vn.net.click.model.ThucUong;
import vn.net.click.model.User;

public class ManagementDAO {
	private JdbcTemplate objJdbc;
	private DataSource dataSource;

	public JdbcTemplate getObjJdbc() {
		return objJdbc;
	}

	public void setObjJdbc(JdbcTemplate objJdbc) {
		this.objJdbc = objJdbc;
	}

	public DataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
		setObjJdbc(new JdbcTemplate(dataSource));
	}

	public ArrayList<ThucUong> getAllThucUongs() {
		ArrayList<ThucUong> thucUongs = null;
		List<ThucUong> list;
		String sql = "select * from thucuong";
		list = objJdbc.query(sql, new ThucUongMapper());
		thucUongs = new ArrayList<ThucUong>(list);
		return thucUongs;
	}

	public ArrayList<User> getAllUsers() {
		
		ArrayList<User> users = null;
		List<User> list;
		String sql = "select * from cf_user";
		list = objJdbc.query(sql, new UserMapper());
		users = new ArrayList<User>(list);
		return users;
	}
	
	

}
